String Interpolation in JavaScript

What is String Interpolation?

String interpolation is a process in JavaScript that is used to embed an expression, variable, or function into a string of text. With the help of this we can embed an expression and to embed an expression we use the template literals or backticks (`) instead of normal quotes. The template literal syntax has a dollar sign that is followed by curly brackets in JavaScript. We can write the expression or mathematical calculation inside the curly brackets. In simple words, by using a String interpolation we can make multi-line strings without the need of an escape character.

Syntax

The syntax of string interpolation is as follows: div class="container">

        
        
            string text`  
            `string text ${expression} string text`